<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: shop_image.php 32531 2015-12-09 20:32:43Z mpage $
 */

if(!defined('IN_DISCUZ') || empty($_GET['pic']) || empty($_GET['size'])) {
	header('location: '.$_G['siteurl'].'static/image/common/none.gif');
	exit;
}

$type = !empty($_GET['type']) ? $_GET['type'] : '2';
list($w, $h) = explode('_', $_GET['size']);
$thumb = 'image/'.substr(md5($_GET['pic']), 0, 2).'/'.substr(md5($_GET['pic']), 2, 2).'/'.substr(md5($_GET['pic']), 4, 2).'/'.substr(md5($_GET['pic']), -16).'_'.$_GET['size'].'.jpg';
if(file_exists($_G['setting']['attachdir'].$thumb)) {
	dheader('location: '.$_G['setting']['attachurl'].$thumb);
}

define('NOROBOT', TRUE);

if($_G['setting']['ftp']['on']) {
	$file = $_G['setting']['ftp']['attachurl'].'portal/'.$_GET['pic'];
} else {
	$file = $_G['setting']['attachdir'].'portal/'.$_GET['pic'];
}
require_once libfile('class/image');
$img = new image;
if($img->Thumb($file, $thumb, $w, $h, $type)) {
	dheader('location: '.$_G['setting']['attachurl'].$thumb);
} else {
	dheader('Content-Type: image');
	@readfile($filename);
}

?>